package com.tjc.ratelimit;

/**
 * @Author: tjc
 * @description
 * @Date Created in 23:35 2022-02-20
 */
class Gateway {
    private UserService userService = new UserService();
    private RateLimitPolicy ratePolicy;

    public Gateway(RateLimitPolicy ratePolicy) {
        this.ratePolicy = ratePolicy;
    }

    public String getName() {
        if(!ratePolicy.access("getName")) {
            return "api flow limiting.";
        }
        return userService.getName();
    }
}
